package wyp.library.ui.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

public abstract class WypNavigationBar extends RelativeLayout {

	public WypNavigationBar(Context context) {
		super(context);
		initView();
	}

	public WypNavigationBar(Context context, AttributeSet attrs) {
		super(context, attrs);
		initView();
	}

	public WypNavigationBar(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		initView();
	}

	protected View leftBtn;
	protected View rightBtn;
	protected View titleView;

	protected abstract void initView();

	public void setTitle(String _title) {
		try {
			if (this.titleView instanceof TextView) {
				((TextView) this.titleView).setText(_title);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public View getLeftBtn() {
		return leftBtn;
	}

	public void setLeftBtn(View _liftBtn) {
		if (this.leftBtn != null) {
			try {
				super.removeView(this.leftBtn);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		this.leftBtn = _liftBtn;
		super.addView(this.leftBtn);
	}

	public View getRightBtn() {
		return rightBtn;
	}

	public void setRightBtn(View _rightBtn) {
		if (this.rightBtn != null) {
			try {
				super.removeView(this.rightBtn);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		this.rightBtn = _rightBtn;
		super.addView(this.rightBtn);
	}

	public View getTitleView() {
		return titleView;
	}

	public void setTitleView(View _titleView) {
		if (this.titleView != null) {
			try {
				super.removeView(this.titleView);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		this.titleView = _titleView;
		super.addView(this.titleView);
	}

}
